<template>
  <div class="pic">
    <img
      src="https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg"
      alt=""
    />
    <p :style="{ backgroundColor: allColor }" @click="change">一只狗</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      allColor: "",
    };
  },
  methods: {
    change() {
      this.allColor = `rgb(${Math.floor(Math.random() * 256)},${Math.floor(
        Math.random() * 256
      )},${Math.floor(Math.random() * 256)})`;
      console.log(this.allColor);
    },
  },
};
</script>

<style scoped>
.pic {
  height: 250px;
  width: 300px;
  border: 2px solid #000;
  text-align: center;
  float: left;
}
img {
  height: 200px;
  width: 100%;
}
p {
  width: 300px;
  /* background-color: pink; */
}
</style>